package com.yxw.yxnet_cd_center.customer_service.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.customer_service.dto.UserChooseDTO;
import com.yxw.yxnet_cd_center.customer_service.entity.YxCsUserEntity;
import com.yxw.yxnet_cd_center.customer_service.entity.YxCsWorkflowEntity;
import com.yxw.yxnet_cd_center.customer_service.mapper.UserMapper;
import com.yxw.yxnet_cd_center.customer_service.service.UserService;
import com.yxw.yxnet_cd_center.customer_service.utils.PageUtils;
import com.yxw.yxnet_cd_center.customer_service.vo.UserChooseVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 客服人员管理
 * @author liuxin
 * @date 2023.09.
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, YxCsUserEntity> implements UserService {


    @Autowired
    private UserMapper  userMapper;
    /**
     * 客服人员选择
     * @param dto
     * @return
     */
    @Override
    public PageVO<UserChooseVo> getChooseUserList(UserChooseDTO dto) {
        Page<UserChooseVo> page = new Page<>(dto.getCurrPage(), dto.getPageSize());
        //群处理
        if(StringUtils.isNotBlank(dto.getFlockId())){
            List<Long> flockList=new ArrayList<>();
            String[] flockArr = dto.getFlockId().split(",");
            for (int i = 0; i <flockArr.length ; i++) {
                flockList.add(Long.valueOf(flockArr[i]));
            }
            dto.setFlockIdList(flockList);
        }
        List<UserChooseVo > voList=userMapper.getChooseUserList(page,dto);
        return PageUtils.get(page,voList);
    }
}
